----------------------------------Spell Variables--------------------------------------
SPELL.m_iSpellID = 10 -- Whatever value you want as long as it doesn't override any other spells' IDs.
SPELL.m_iRange = 240
SPELL.m_sName = "Slam"
SPELL.m_sToolTip =	[[A mighty swing that slams
					the target for 100% weapon
					damage.]]
SPELL.m_sIcon = "devin/blackbetty/spells/warrior/slam.png"
SPELL.m_iCoolDown = 5
SPELL.m_iManaCost = 15
SPELL.m_bRequiresTarget = true
SPELL.m_iSpellType = SPELLTYPE_MELEEDAMAGE

---------------------------------------------------------------------------------------

function SPELL:Cast( pl, target )
	local target = nil
	local weapon = nil
	if(pl:IsPlayer())then
		weapon = pl:GetWeapon("weapon_all")
		target = pl:GetNetworkedEntity("Target")
	else
		target = pl.Target
	end
	if(target && target:IsValid() && target != pl) then
		pl:DoAnimationEvent(ACT_HL2MP_GESTURE_RANGE_ATTACK_MELEE2)
		pl:EmitSound("devin/blackbetty/weapons/slam/swing_"..math.random(1,3)..".wav", 100, 100+math.random(-10,10))
		if(pl:GetPos():Distance(target:GetPos()) < self.m_iRange)then
			timer.Simple(0.3, function()
				ParticleEffectAttach( "slam", PATTACH_POINT_FOLLOW, pl, pl:LookupAttachment("anim_attachment_RH"))
				--pl:EmitSound("devin/blackbetty/weapons/slam/hit_1.wav", 150, 100+math.random(-10,10))
				pl:EmitSound("devin/blackbetty/weapons/heroic_strike/heroic_strike.wav", 150, 100+math.random(-10,10))
				ParticleEffect( "pummel_hit", target:GetPos() + Vector(0, 0, 46) + (target:GetAngles():Forward()*6), Angle(0,0,0), pl )
				ParticleEffect( "player_blood", target:GetPos() + Vector(0, 0, 46) + (target:GetAngles():Forward()*6), Angle(0,0,0), pl )
				print(target)
				if SERVER then
					local dmginfo = DamageInfo()
						dmginfo:SetDamage( math.Round(math.random(weapon.MinWeaponDamage*2, weapon.MaxWeaponDamage*2)) ) --50 damage
						dmginfo:SetDamageType( DMG_SLASH ) --Bullet damage
						dmginfo:SetAttacker( pl ) --First player found gets credit
						dmginfo:SetDamageForce( Vector( 0, 0, 1000 ) ) --Launch upwards
					target:TakeDamageInfo( dmginfo )
				end	
			end)
		timer.Simple(0.4, function()
			pl:SetNWBool("Casting", false)
			pl:SetNWBool("Casted", false)
		end)
	end
	end
end



